package com.atguigu.Utils;

/**
 * 基于ThreadLocal封装工具类，保存获取当前用户的id
 * 作用域为一个线程内
 */
public class BaseContext {
    //员工id
    private static ThreadLocal<Long> threadLocal=new ThreadLocal<>();
    //用户id
    private static ThreadLocal<Long> currentId=new ThreadLocal<>();

    public static void setThreadLocal(Long id){
        threadLocal.set(id);
    }

    public static Long getThreadLocal(){
        return threadLocal.get();
    }

    public static void setCurrentId(Long id){currentId.set(id);}

    public static Long getCurrentId(){return currentId.get();}
}
